<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm"  :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="检测结果" prop="result">
        <el-select v-model="queryParams.result" placeholder="请选择检测结果" clearable>
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search"  @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh"  @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>


    <el-table v-loading="loading" :data="jobList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="四性检测方案标识" width="100" align="center" prop="code" />
      <el-table-column label="接收时间" align="center" prop="createTime" :show-overflow-tooltip="true" />
      <el-table-column label="解析时间" align="center" prop="detectionTime" :show-overflow-tooltip="true" />
      <el-table-column label="包名称" align="center" prop="name" :show-overflow-tooltip="true" />
      <el-table-column label="接收地址" align="center" prop="path" :show-overflow-tooltip="true" />
      <el-table-column label="检测结果" align="center" prop="result">
        <template slot-scope="scope">
          <span>{{ scope.row.result === '0' ? '通过' : scope.row.result === '1' ? '不通过' : '未检测' }}</span>
        </template>
      </el-table-column>



    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listJob, fetchData } from "@/api/archive/receiveLog/receiveLog";


export default {

  name: "Job",

  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 定时任务表格数据
      jobList: [],
      // 弹出层标题
      title: "",

      // 传入的表达式
      expression: "",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        result: '' // 初始值为空，表示没有选择
      },
      options: [
        {
          value: '0',
          label: '不通过'
        },
        {
          value: '1',
          label: '通过'
        }
      ],
      tooltipContent: '加载中...' // 初始状态显示加载信息
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询定时任务列表 */
    getList() {
      this.loading = true;
      listJob(this.queryParams).then(response => {
        this.jobList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },




    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.jobId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('schedule/job/export', {
        ...this.queryParams
      }, `job_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
